package net.dirox.confluence.plugin.web.contextproviders;

import java.util.HashMap;
import java.util.Map;

import com.atlassian.confluence.core.FormAware;
import com.atlassian.confluence.user.actions.AbstractUserProfileAction;
import com.atlassian.core.AtlassianCoreException;

public class ViewMyNotes extends AbstractUserProfileAction implements
		FormAware { //, ParameterAware {
	private static final long serialVersionUID = 1L;
	private static final String PROPERTY_USER_DASHBOARD_ACTIVITYSTREAM_ENABLED = "user.dashboard.activitystream.enabled";

	private boolean editMode = false;
    private String word; 
	public String getWord() {
		return word;
	}

	public void setWord(String word) {
		this.word = word;
	}

	private boolean activityStreamEnabled = false;
	
	public String doView() throws Exception {
		return SUCCESS;
	}

	public String doInput() throws Exception {
		editMode = true;
		return INPUT;
	}

	@Override
	public String execute() throws Exception {
		updateUser();
		Map contextMap = new HashMap();
		setWord("AloAlo");
		//ActionContext.getContext().setContextMap(contextMap);
		return SUCCESS;
	}

	private void updateUser() throws AtlassianCoreException {
		getUserPreferences().setBoolean(
				PROPERTY_USER_DASHBOARD_ACTIVITYSTREAM_ENABLED,
				activityStreamEnabled);
	}

	public boolean isActivityStreamEnabled() {
		return getUserPreferences().getBoolean(
				PROPERTY_USER_DASHBOARD_ACTIVITYSTREAM_ENABLED);
	}

	public void setActivityStreamEnabled(boolean activityStreamEnabled) {
		this.activityStreamEnabled = activityStreamEnabled;
	}

	@Override
	public boolean isPermitted() {
		return getUsername() != null && super.isPermitted();
	}

	@Override
	public boolean isEditMode() {
		return editMode;
	}

//	@Override
//	public void setParameters(Map params) {
//		// TODO Auto-generated method stub
//		params.put("tommy", "Hello ngay moi");
//	}
}
